Hello there, trying to write a program to use proper capitalization on an input sentance. Here's what I have but its compiling and giving me back gobbildy-gook, can someone lend a hand? cheers. Shane.
Code:
#include <stdio.h>
int main(void)
{
char text[200];
int i = 0;
printf("Enter text:");
gets(text);
/*First letter is always capital*/
if(text[i] > 96 && text[i] < 123)
{
text[i] = text[i] - 32;
printf("%c", text[i]);
i++;
}
else
{
printf("%c", text[i]);
}
/*Eliminating random capitals throughout the sentance*/
while(text[i] != '\0')
{
if(text[i] > 64 && text[i] < 91);
{
text[i] = text[i] + 32;
printf("%c", text[i]);
}
if(text[i] > 96 && text[i] < 123)
{
printf("%c", text[i]);
}
if(text[i] == '.') //Capitalizing after a full stop
{
i = i + 2; //i + 2 because there is a space after a full stop
if(text[i] > 64 && text[i] < 91);
{
text[i] = text[i] + 32;
printf("%c", text[i]);
}
if(text[i] > 96 && text[i] < 123)
{
printf("%c", text[i]);
}
}
i++;
}
}